import request from '@/utils/request'

// 查询素材资源列表
export function listAssets(query) {
  return request({
    url: '/knowledge/assets/v1/list',
    method: 'get',
    params: query
  })
}

// 查询素材资源详细
export function getAssets(id) {
  return request({
    url: '/knowledge/assets/v1/' + id,
    method: 'get'
  })
}

export function getPreviewData(id){
  return request({
    url: '/knowledge/assets/v1/preview/'+id,
    method: 'get'
  });
}

export function getDownloadUrl(id){
  return request({
    url: '/knowledge/assets/v1/download-url/'+id,
    method: 'get'
  });
}


// 新增素材资源
export function addAssets(data) {
  return request({
    url: '/knowledge/assets/v1',
    method: 'post',
    data: data
  })
}

// 修改素材资源
export function updateAssets(data) {
  return request({
    url: '/knowledge/assets/v1',
    method: 'put',
    data: data
  })
}

// 删除素材资源
export function delAssets(id) {
  return request({
    url: '/knowledge/assets/v1/' + id,
    method: 'delete'
  })
}

// 素材资源类型
export function assetsTypeList(){
  return request({
    url: '/knowledge/assets/v1/assets-type',
    method: 'get'
  })
}

export function addFolder(folder){
  return request({
    url: '/knowledge/assets-folder/v1',
    method: 'post',
    data: folder
  })
}

export function updateFolder(folder){
  return request({
    url: '/knowledge/assets-folder/v1',
    method: 'put',
    data: folder
  })
}

export function getFolder(id){
  return request({
    url: '/knowledge/assets-folder/v1/'+ id,
    method: 'get'
  })
}

export function delFolder(ids) {
  return request({
    url: '/knowledge/assets-folder/v1/' + ids,
    method: 'delete'
  })
}

export function folderTree(query) {
  return request({
    url: '/knowledge/assets-folder/v1/tree',
    method: 'get',
    params: query
  })
}
